import cooApp, { ui, coolink, Util, cooInfo } from 'coolink-ts'
import pageList from './pages/pageList'

// 注册页面
pageList.registerAllPage();

// flutter 环境准备就绪
cooApp.ready = () => {
  ui.setAppBarHeight(ui.rpx(88));
  let frameworkVersion = 1;
  if (cooInfo.infos?.appInfo?.frameworkVersion) {
    frameworkVersion = Number(cooInfo.infos.appInfo.frameworkVersion);
  }
  if (frameworkVersion > 1) {
    coolink.baseinfo.getResourcePath()
      .then((res) => {
        let path = res.path;
        let lastCh = '';
        if (path.length > 0) lastCh = path.substr(-1);
        if (lastCh != '/') path += '/';
        Util.log('mypath = ' + path);
        cooApp.setResourcePath(path);
        cooApp.runApp()
        //
      })
  } else {
    cooApp.runApp();    // 运行程序
  }
}
